<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
  <head>
    <link href="css/style.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="bin/prototype.js"></script>
    <script type="text/javascript" src="bin/functions.js"></script>
    <script type="text/javascript" src="bin/library.js"></script>


    <title> LYON UNO </title>
  </head>

  <body>

    <div id="head_pic">
      <img src="images/title.png" alt="[LYON UNO]" id="picture">
    </div>

    <div id="webpage">

<p>Here you can edit your profile</p>
<hr>

<?php
/*$host = "localhost";
$user = "ampersand";
$pass = "palomitas";
$dbname = "LYONUNO";*/

$hostDB = "localhost";
$userDB = "ampersand";
$passDB = "palomitas";
$dbnameDB = "LYONUNO";

$cook = $_COOKIE["loggedIn"];

$canalDB = mysql_connect($hostDB, $userDB, $passDB);
$db = mysql_select_db($dbnameDB);
$consulta = 'select * from USERS where nick=\''.$cook.'\'';

$resDB = mysql_db_query($dbnameDB, $consulta,$canalDB);

echo "<form method=\"POST\" action=\"/update.php\" onsubmit=\"return validate_prof(this)\" name=\"formul_profile\">";
echo "<table>\n<tr>\n<td>Login Name</td>\n<td>";
if($row = mysql_fetch_object($resDB)){
	$nick = $row->nick;
	$name = $row->name;
	$day = date(d,strtotime($row->birthday));
	$month = date(m,strtotime($row->birthday));
	$year = date(Y,strtotime($row->birthday));
	$email = $row->email;
	$country = $row->country_code;
	$webpage = $row->webpage;
}
mysql_free_result($resDB);

echo "<input type=\"text\" readOnly maxlength=\"50\" size=\"20\" name=\"userP\" value = \"$nick\" /></td>\n</tr>";
?>

<tr>
	<td>	Old password	</td>
	<td>	<input type="password" name="oldPasswordP">		</td>
</tr>
<tr>
	<td>	Choose a new password	</td>
	<td>	<input type="password" name="passwordP"> <span id="errorPassword"></span>		</td>
</tr>
<tr>
	<td>	Re-enter new password	</td>
	<td>	<input type="password" name="password2P">	</td>
</tr>

<?php
echo "<tr>\n<td>	Name	</td>\n";
echo "<td>	<input type=\"text\" maxlength=\"50\" size=\"20\" name=\"nameP\" value=\"$name\" /> <span id=\"errorName\"></span>	</td>";
echo "</tr>\n<tr>\n	<td>	Birhtday (DD/MM/YYYY)	</td>";
echo "<td>	<input type=\"text\" maxlength=\"2\" size=\"2\" name=\"dayP\" value=\"$day\" />/";
echo "<input type=\"text\" maxlength=\"2\" size=\"2\" name=\"monthP\" value=\"$month\" />/";
echo "<input type=\"text\" maxlength=\"4\" size=\"4\" name=\"yearP\" value=\"$year\" />	<span id=\"errorDate\"></span> </td>";
echo "</tr>\n<tr>\n<td>	E-mail	</td>";
echo "<td>	<input type=\"text\" maxlength=\"50\" size=\"20\" name=\"emailP\" value=\"$email\"/> <span id=\"errorEmail\"></span>	</td>";
echo "</tr>\n<tr>\n<td>	Country	</td>";

$consulta = 'select name,code from COUNTRIES order by name asc';

$resDB = mysql_db_query($dbnameDB, $consulta,$canalDB);

echo "<td> <select name=\"countryP\">\n";

while($row = mysql_fetch_object($resDB)){
	$name = $row->name;
	$code = $row->code;
	if($code == $country)
		echo "<option VALUE=\"$code\" selected >$name</OPTION>\n";
	else
		echo "<option VALUE=\"$code\">$name</OPTION>\n";
}
echo "</select></td></tr>\n";
echo "</tr>\n<tr>\n<td>	Webpage	</td>";
echo "<td>	<input type=\"text\" maxlength=\"50\" size=\"20\" name=\"webpP\" value=\"$webpage\" />	</td>\n</tr>";

mysql_free_result($resDB);
mysql_close($canalDB);
?>

<tr>
	<td>	Picture URL	</td>
	<td>	<input type="text" maxlength="200" size="20" name="picP" />	</td>
</tr>
</table>
<input type="submit" name= "but" value="Update"/>
</form>
<br>
<a href="main.php"> Back to the main page</a>
    </div>

    <div id="foot">
      <address>LYON UNO. CPE <br> 43, boulevard du 11 Novembre 1918. BP 2077 <br> 69616 Villeurbanne Cedex </address>
    </div>
  </body>
</html>
